package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ISendVerifyCodeService;
import cn.wolfcode.trip.base.service.IUserService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;

    @Autowired
    ISendVerifyCodeService sendVerifyCodeService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") QueryObject qo, Model model){
        model.addAttribute("pageInfo",userService.query(qo));
        return "user/list";
    }

    /**
     * 升级或是取消会员
     */
    @RequestMapping("/vip")
    @ResponseBody
    public JSONResult becomeOrLostVip(Long id  , Boolean vip ){
        userService.becomeOrLostVip(id ,vip);
        return new JSONResult();
    }
}
